package com.gxufl.service;

import java.util.List;

import com.gxufl.Application;
import com.gxufl.dao.SeatDao;
import com.gxufl.dao.TicketDao;
import com.gxufl.entity.Ticket;
import com.gxufl.util.BackException;
import com.gxufl.util.JdbcUtil;

public class TicketService {
	
	TicketDao dao = new TicketDao();
	SeatDao seatDao = new SeatDao();

	public Ticket saveTicket(Ticket ticket) throws BackException {
		
		boolean isOK = seatDao.checkBeforeSaveTictet(ticket);
		if(!isOK) {
			System.out.println("票据验证不通过！请从新输入");
			Application.fn显示售票录入();
			return null;
		}
		
		// TODO:(完成)只要符合座位编号正确，并且没有人使用的情况，才能保存
		ticket = dao.save(ticket);
		return ticket;
	}

	/**
	 * 根据条件查询票据信息列表
	 */
	public List<Ticket> searchTicket(String noticeName, String roomName) {
		return dao.findList(noticeName, roomName);
	}
	
	/**
	 * 通过用户手机号，查询票据信息
	 */
	public Ticket findOneByUsertel(String usertel) {
		return dao.findOneByUsertel(usertel);
	}

}
